package com.pay.controller.api.backend;

import com.pay.common.JsonResult;
import com.pay.common.ProcessAPI;
import com.pay.controller.Routes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author Evan
 * @date 2017/10/26
 */
@RestController
@Api(value = "hello", description = "hello")
public class HelloWorldController {
    private Logger logger = LoggerFactory.getLogger(HelloWorldController.class);

    @RequestMapping(value = Routes.HOME,method = RequestMethod.GET)
    @ApiOperation(value = "最简单的实例", notes = "最简单的实例", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    public JsonResult hello(HttpServletRequest request){
        ProcessAPI api = (jsonResult, validate) -> {
            logger.info("Hello World!");
            jsonResult.setResult("Hello World!");
        };
        return api.process(request);
    }
}
